package com.hduong.springcloud;

import com.hduong.config.MySelfRule;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.ribbon.RibbonClient;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

/**
 * Created by dudu on 2020/3/17.
 */
@SpringBootApplication
@EnableEurekaClient
//自定义 负载均衡算法 : 访问服务
//@RibbonClient(name = "BEFORE-CLOUD-PAYMENT-SERVICE", configuration = MySelfRule.class)
public class CloudConsumerOrder80 {
    public static void main(String[] args) {
        SpringApplication.run(CloudConsumerOrder80.class, args);
    }

    /**
     * http请求对象 : 类似 httpClient
     * @return
     */
    @Bean
//    @LoadBalanced//添加负载均衡机制 ： 针对使用服务名称时候必须指定
    //给与了 RestTEmplate 负载均衡的能力
    // 引出 ribbon 负载均衡 --》 涉及到多个设计模式i
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }
}
